package com.ruoyi.read.mapper;

import java.util.List;
import com.ruoyi.read.domain.SysNoticeRead;
import com.ruoyi.system.domain.SysNotice;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * readMapper接口
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
public interface SysNoticeReadMapper 
{
    /**
     * 查询read
     * 
     * @param id readID
     * @return read
     */
    public SysNoticeRead selectSysNoticeReadById(Long id);



@Select("select * from sys_notice_read where user_id=#{userId} and notice_id=#{noticeId} limit 1")
    public SysNoticeRead selectSysNoticeReadByUserIdAndNoticeId(SysNoticeRead sysNoticeRead);
    @Select("SELECT " +
            "n.notice_id AS noticeId, " +
            "n.notice_title AS noticeTitle, " +
            "n.notice_type AS noticeType, " +
            "n.notice_content AS noticeContent, " +
            "n.status AS status, " +
            "n.create_by AS createBy, " +
            "n.create_time AS createTime, " +
            "n.update_by AS updateBy, " +
            "n.update_time AS updateTime, n.du as du,n.users as users ,n.depts as depts, " +
            "n.remark AS remark " +
            "FROM sys_notice n " +
            "LEFT JOIN sys_notice_read r ON n.notice_id = r.notice_id AND r.user_id = #{userId} " +
            "WHERE r.notice_id IS NULL and n.status = 0")
    List<SysNotice> getUnreadNoticesByUserId(@Param("userId") Long userId);

    /**
     * 查询read列表
     * 
     * @param sysNoticeRead read
     * @return read集合
     */
    public List<SysNoticeRead> selectSysNoticeReadList(SysNoticeRead sysNoticeRead);

    /**
     * 新增read
     * 
     * @param sysNoticeRead read
     * @return 结果
     */
    public int insertSysNoticeRead(SysNoticeRead sysNoticeRead);

    /**
     * 修改read
     * 
     * @param sysNoticeRead read
     * @return 结果
     */
    public int updateSysNoticeRead(SysNoticeRead sysNoticeRead);

    /**
     * 删除read
     * 
     * @param id readID
     * @return 结果
     */
    public int deleteSysNoticeReadById(Long id);

    /**
     * 批量删除read
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteSysNoticeReadByIds(Long[] ids);
}
